package com.up.upzl.biz.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import com.up.upzl.base.domain.BaseDomain;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 文章分类管理
 * 
 * @author Youke
 *
 */
@Getter
@Setter
@Entity
@NoArgsConstructor
public class ArticleCategory extends BaseDomain {

	private static final long serialVersionUID = -2163615259105680177L;

	/**
	 * 分类名称
	 */
	@Column(length = 32)
	private String name;

	/**
	 * 父级应用
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parentId")
	private ArticleCategory parentArticleCategory;

	/**
	 * 子级应用
	 */
	@OneToMany(mappedBy = "parentArticleCategory")
	private List<ArticleCategory> subArticleCategory;

	/**
	 * 是否发布
	 */
	private Boolean publish;

	@Transient
	public String getPublishText() {
		if (publish) {
			return "是";
		} else {
			return "否";
		}
	}

	/**
	 * 标签类型
	 */
	private Type type;

	public enum Type {
		新闻, 活动, 论坛, 需求
	}

	/**
	 * 展示数量
	 */
	private Integer showNum;

	/**
	 * 排序
	 */
	private Integer sort;

}
